package com.jackie.tongzhuang.Adapters;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.jackie.tongzhuang.Models.FenQi;
import com.jackie.tongzhuang.Models.GongHuoShang;
import com.jackie.tongzhuang.R;

import java.util.List;

public class FenQiCardAdapter extends BaseAdapter {
    private Context context;
    private List<FenQi> items;



    public FenQiCardAdapter(Context context, List<FenQi> items) {
        this.context = context;
        this.items = items;
    }

    @Override
    public int getCount() {
        return items.size();
    }

    @Override
    public Object getItem(int position) {
        return items.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int i, View convertView, ViewGroup parent) {
        if (convertView == null) {
            convertView = LayoutInflater.from(context).inflate(R.layout.control_fenqicard, parent, false);
        }
        TextView t_qs = convertView.findViewById(R.id.fqc_qs);
        t_qs.setText(items.get(i).getQiShu()+" 期");
        TextView t_hke = convertView.findViewById(R.id.fqc_hke);
        t_hke.setText("¥"+items.get(i).getFenQiJinE());
        TextView t_rq = convertView.findViewById(R.id.fqc_rq);
        t_rq.setText(items.get(i).getChangHuanRiQi());
        TextView t_bjlx = convertView.findViewById(R.id.fqc_bjlx);
        t_bjlx.setText("含本金 ¥"+items.get(i).getBenJin()+"  含利息 ¥"+items.get(i).getLiXi());

        ImageView img = convertView.findViewById(R.id.fqc_ch);
        if(items.get(i).getYiChangHuan() == 1){
            img.setVisibility(View.VISIBLE);
        }else{
            img.setVisibility(View.GONE);
        }
        return convertView;
    }
}